package com.lagou.myspringboot;

import org.apache.catalina.LifecycleException;
import org.apache.catalina.startup.Tomcat;

import javax.servlet.ServletException;

public class SpringApplication {

    private static Class configClass;

    public static void run(Class<?> primarySource) {
        configClass = primarySource;
        try {
            //启用tomcat
            Tomcat tomcat = new Tomcat();
            tomcat.setPort(8130);
            tomcat.addWebapp("/", "D:\\");

            tomcat.start();
            tomcat.getServer().await();
        } catch (LifecycleException e) {
            e.printStackTrace();
        } catch (ServletException e) {
            e.printStackTrace();
        }

    }

    public static Class getConfigClass() {
        return configClass;
    }
}
